package com.ljm.controller;

import com.ljm.common.Pyment;
import com.ljm.common.R;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class RestContoller {

    @Value("${server.port}")
    private String serverPort;

    private  static HashMap<Long, Pyment>  hashmap =  new HashMap<>();

    static {
        hashmap.put(1L,new Pyment(1L,"s1da356fe6s122fkjdz09nf"));
        hashmap.put(2L,new Pyment(2L,"31da309lk8yyui2fkjd73nf"));
        hashmap.put(3L,new Pyment(3L,"81a34356fae8dfert8492edz9"));
    }

    @GetMapping(value = "/payment/nacos/{id}")
    public String getPayment(@PathVariable("id") Integer id){
        return "nacos registry,serverPort:" + serverPort + "\t id" + id;
    }

    @GetMapping(value = "/payment/{id}")
    public R payment(@PathVariable("id") Long id){

        Pyment pyment = hashmap.get(id);
        return R.ok().data("pyment",pyment);
    }



}
